// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: WriteTag.java

package com.market.web.tag;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.struts.taglib.TagUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WriteTag extends TagSupport
{

    private static final Logger logger  = LoggerFactory.getLogger(WriteTag.class.getName());
    /**
     * 
     */
    private static final long serialVersionUID = 7459614601344386245L;

    public WriteTag()
    {
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getProperty()
    {
        return property;
    }

    public void setProperty(String property)
    {
        this.property = property;
    }

    public int doEndTag() throws JspException
    {
        TagUtils t = TagUtils.getInstance();
        Object o = t.lookup(pageContext, name, null);
        String str = "";
        if (!StringUtils.isEmpty(property))
            try
            {
                str = PropertyUtils.getProperty(o, property).toString();
            }
            catch (Exception e)
            {
                logger.error("",e);
            }
        else
        {
            str = o.toString();
        }
        t.write(pageContext, str.replaceAll("[<]", "&lt;").replaceAll("[>]", "&gt;").replaceAll("[\n]", "<br>")
                .replaceAll("[ ]", "&nbsp;"));
        return 6;
    }

    public int doStartTag() throws JspException
    {
        return 0;
    }

    private String name;

    private String property;
}
